﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using SAC.sqlHelper;
using SAC.Elink;
using SAC.Helper;
using System.Collections;
using System.Data;
using SAC.Power;


namespace DAL
{
    public class DALRep
    {
        int count;
        int countKey;

        string sql = "";
        string errMsg = "";

        Elink ek = new Elink();
        StrHelper sh = new StrHelper();
        PowerCale pc = new PowerCale();
        DALPubMehtod pm = new DALPubMehtod();
        DALUtilityMehtod um = new DALUtilityMehtod();
        SAC.Helper.LogHelper lh = new LogHelper();

        /// <summary>
        /// 值报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="unit"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepVal(string repName, string date, int unit, string bName, out string bzID, out string bzTime)
        {
            int id;
            object obj;
            object objVal;

            double drvA = 0;

            string bm = "";
            string num = "";
            string mon = "";
            string res = "";
            string dlID = "";
            string qsrq = "";
            string jsrq = "";

            ArrayList list = new ArrayList();

            bzID = "";
            bzTime = "";

            count = pm.GetCount(repName, unit);
            countKey = pm.GetCountkey(repName, 1);

            DateTime dtNow = DateTime.Now;

            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;

            string[] dvExcel = null;


            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 值报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            try
            {
                zb = new string[count + 1];
                un = new string[count + 1];
                lay = new string[count + 1];
                dv = new string[count + 1];
                du = new string[countKey + 1];

                dvExcel = new string[count + 1];

                //直接取出中文描速,单位,设计值
                sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

                DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

                if (dtInfo != null && dtInfo.Rows.Count > 0)
                {
                    for (int k = 0; k < dtInfo.Rows.Count; k++)
                    {
                        id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                        zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                        un[id] = dtInfo.Rows[k]["单位"].ToString();
                        lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                    }
                }
                else
                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

                sql = "select * from 排班表 where 起始时间 between '" + Convert.ToDateTime(date).ToString("yyyy-MM-dd 0:00:00") + "' and '" + Convert.ToDateTime(date).ToString("yyyy-MM-dd 23:59:59") + "'";

                DataTable dtLevBZ = DBsql.RunDataTable(sql, out errMsg);

                if (dtLevBZ != null && dtLevBZ.Rows.Count > 0)
                {
                    int a = 1;

                    for (int k = 0; k < dtLevBZ.Rows.Count; k++)
                    {
                        bzID += dtLevBZ.Rows[k]["班组编号"].ToString() + ";";

                        qsrq = dtLevBZ.Rows[k]["起始时间"].ToString();

                        jsrq = DateTime.Parse(dtLevBZ.Rows[k]["结束时间"].ToString()).AddSeconds(+1).ToString("yyyy-MM-dd H:00:00");

                        bzTime += qsrq + "," + jsrq + ";";

                        if (dtNow > DateTime.Parse(jsrq))
                        {
                            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";
                            //sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0 and 公式级别!=0";
                            DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                            if (dtLel.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtLel.Rows.Count; j++)
                                {
                                    string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                                    #region 平均

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                                    DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtAvg != null && dtAvg.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtAvg.Rows.Count; i++)
                                        {
                                            num = dtAvg.Rows[i]["小数点数"].ToString();

                                            if (dtLevBZ.Rows[k]["班组编号"].ToString() != "" && dtAvg.Rows[i]["统计ID"].ToString() != "")
                                                sql = "select 统计值 from " + bName + " where 时间='" + date + "' and 机组=" + unit + " and 班组=" + dtLevBZ.Rows[k][
                                                    "班组编号"].ToString() + " and 统计ID ='" + dtAvg.Rows[i]["统计ID"].ToString() + "'";
                                            else
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: 班组编号 || 统计ID 为空" + sql);

                                            objVal = DBsql.RunSingle(sql, out errMsg);

                                            if (objVal != null && objVal.ToString() != "")
                                            {
                                                if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(objVal.ToString(), num) + ",";

                                                    dvExcel[id] += objVal.ToString() + ",";
                                                }

                                                if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                                    du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + objVal.ToString() + ";";
                                                    //du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(objVal.ToString(), num) + ";";
                                                }
                                            }
                                            else
                                            {
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: " + sql);

                                                if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += "0,";
                                                    dvExcel[id] += "0,";
                                                }

                                                if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                                    du[id] += dtAvg.Rows[i]["参数ID"].ToString() + ",0;";
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 累计

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                                    DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtDiff != null && dtDiff.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtDiff.Rows.Count; i++)
                                        {
                                            num = dtDiff.Rows[i]["小数点数"].ToString();

                                            if (dtLevBZ.Rows[k]["班组编号"].ToString() != "" && dtDiff.Rows[i]["统计ID"].ToString() != "")
                                                sql = "select 统计值 from " + bName + " where 时间='" + date + "' and 机组=" + unit + " and 班组=" + dtLevBZ.Rows[k]["班组编号"].ToString() + " and 统计ID =                                            '" + dtDiff.Rows[i]["统计ID"].ToString() + "'";
                                            else
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: 班组编号 || 统计ID 为空" + sql);

                                            objVal = DBsql.RunSingle(sql, out errMsg);

                                            if (objVal != null && objVal.ToString() != "")
                                            {
                                                if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(objVal.ToString(), num) + ",";

                                                    dvExcel[id] += objVal.ToString() + ",";
                                                }

                                                if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                                    du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + objVal.ToString() + ";";
                                                    //du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(objVal.ToString(), num) + ";";
                                                }
                                            }
                                            else
                                            {
                                                if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += "0,";
                                                    dvExcel[id] += "0,";
                                                }

                                                if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                                    du[id] += dtDiff.Rows[i]["参数ID"].ToString() + ",0;";
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 电量
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtDL.Rows.Count > 0 && dtDL != null)
                                    {
                                        for (int i = 0; i < dtDL.Rows.Count; i++)
                                        {
                                            num = dtDL.Rows[i]["小数点数"].ToString();

                                            dlID = dtDL.Rows[i]["电量点"].ToString();

                                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                                            mon = "";
                                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                            res = "";
                                            try
                                            { res = StrHelper.Cale(mon); }
                                            catch
                                            { res = "0"; }

                                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(res, num) + ",";

                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            }

                                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                                //  du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                                du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            }
                                        }
                                    }

                                    #endregion

                                    #region SQL

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                                    DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtSQL != null && dtSQL.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtSQL.Rows.Count; i++)
                                        {
                                            num = dtSQL.Rows[i]["小数点数"].ToString();

                                            sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                            if (sql.Contains("&BZ&"))
                                            {
                                                sql = sql.Replace("&BZ&", dtLevBZ.Rows[k]["班组编号"].ToString());
                                                sql = sql.Replace("&bt&", DateTime.Parse(qsrq).ToString("yyyy-MM-dd 0:00:00"));
                                                sql = sql.Replace("&et&", DateTime.Parse(jsrq).AddSeconds(-1).ToString());
                                            }
                                            else if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                            {
                                                sql = sql.Replace("&bt&", qsrq);
                                                sql = sql.Replace("&et&", DateTime.Parse(jsrq).AddSeconds(-1).ToString());
                                            }

                                            obj = DBsql.RunSingle(sql, out errMsg);

                                            res = "";
                                            if (obj != null && obj.ToString() != "")
                                            {
                                                if (obj.ToString() != "")
                                                    res = obj.ToString();
                                                else
                                                    res = "0";
                                            }
                                            else
                                            { res = "0"; }

                                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(res, num) + ",";

                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            }

                                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                                //du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                                du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 其它
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtQT.Rows.Count > 0 && dtQT != null)
                                    {
                                        for (int i = 0; i < dtQT.Rows.Count; i++)
                                        {
                                            num = dtQT.Rows[i]["小数点数"].ToString();

                                            #region 购网电量
                                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                            {
                                                string re = um.gwdl(qsrq, jsrq, unit);

                                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                                    dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                                }

                                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re + ";";
                                                }
                                            }
                                            #endregion

                                            #region 入炉煤低位发热量
                                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                            {
                                                string rlm = um.rlmdwfrl("值报", DateTime.Parse(qsrq).ToString("yyyy-MM-dd 0:00:00"), jsrq, unit, dtLevBZ.Rows[k]["班组编号"].ToString());

                                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(rlm, num) + ",";

                                                    dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                                }

                                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                    //du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";

                                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                                }
                                            }
                                            #endregion

                                            #region K2(q2)
                                            if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                            {
                                                string pid = dtQT.Rows[i]["参数ID"].ToString();

                                                string val = um.K2(pid, du, unit);

                                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(val, num) + ",";

                                                    dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                                }

                                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                    #endregion

                                    #region 公式
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtMon != null && dtMon.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtMon.Rows.Count; i++)
                                        {
                                            num = dtMon.Rows[i]["小数点数"].ToString();

                                            string pMon = dtMon.Rows[i]["公式"].ToString();

                                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                                            string month = pm.retMon(pMon, paras, du, a.ToString());

                                            if (month != "")
                                            {
                                                res = "";
                                                try
                                                {
                                                    res = StrHelper.Cale(month);

                                                    if (dtMon.Rows[i]["显示"].ToString() == "1")
                                                    {
                                                        id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                                    }

                                                    if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                                    {
                                                        id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                                        du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                                    }

                                                    res = sh.ShowPoint(res, num);
                                                }
                                                catch
                                                {
                                                    res = "0";
                                                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 公式 报程序异常: " + pMon + ":" + paras + ":" + month);
                                                }

                                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());
                                                    dv[id] += sh.ShowPoint(res, num) + ",";
                                                }

                                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    //du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                                }
                                            }
                                        }
                                    }

                                    #endregion
                                }
                            }
                            a++;
                        }
                    }
                }
            }
            catch (Exception ce)
            { LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvExcel);

            return list;
        }

        /// <summary>
        /// 值月,季,年报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="date"></param>
        /// <param name="unit"></param>
        /// <param name="bName"></param>
        /// <param name="bzID"></param>
        /// <param name="dd"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepVal(string repName, string date, int unit, string bName, out string bzID, string dd)
        {
            int id;
            object obj;
            object objVal;

            double drvA = 0;

            string bm = "";
            string num = "";
            string mon = "";
            string res = "";
            string dlID = "";
            string qsrq = "";
            string jsrq = "";

            ArrayList list = new ArrayList();

            bzID = "";
            count = pm.GetCount(repName, unit);
            countKey = pm.GetCountkey(repName, 1);

            DateTime dtNow = DateTime.Now;

            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 值报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            try
            {
                zb = new string[count + 1];
                un = new string[count + 1];
                lay = new string[count + 1];
                dv = new string[count + 1];
                du = new string[countKey + 1];

                //直接取出中文描速,单位,设计值
                sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

                DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

                if (dtInfo != null && dtInfo.Rows.Count > 0)
                {
                    for (int k = 0; k < dtInfo.Rows.Count; k++)
                    {
                        id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                        zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                        un[id] = dtInfo.Rows[k]["单位"].ToString();
                        lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                    }
                }
                else
                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

                sql = "select * from 排班表 where 起始时间 between '" + Convert.ToDateTime(date).ToString("yyyy-MM-dd 0:00:00") + "' and '" + Convert.ToDateTime(date).ToString("yyyy-MM-dd 23:59:59") + "'";

                DataTable dtLevBZ = DBsql.RunDataTable(sql, out errMsg);

                if (dtLevBZ != null && dtLevBZ.Rows.Count > 0)
                {
                    int a = 1;

                    for (int k = 0; k < dtLevBZ.Rows.Count; k++)
                    {
                        bzID += dtLevBZ.Rows[k]["班组编号"].ToString() + ";";

                        qsrq = dtLevBZ.Rows[k]["起始时间"].ToString();

                        jsrq = DateTime.Parse(dtLevBZ.Rows[k]["结束时间"].ToString()).AddSeconds(+1).ToString("yyyy-MM-dd H:00:00");

                        if (dtNow > DateTime.Parse(jsrq))
                        {
                            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

                            DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                            if (dtLel.Rows.Count > 0)
                            {
                                for (int j = 0; j < dtLel.Rows.Count; j++)
                                {
                                    string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                                    #region 平均

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                                    DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtAvg != null && dtAvg.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtAvg.Rows.Count; i++)
                                        {
                                            num = dtAvg.Rows[i]["小数点数"].ToString();

                                            if (dtLevBZ.Rows[k]["班组编号"].ToString() != "" && dtAvg.Rows[i]["统计ID"].ToString() != "")
                                                sql = "select 统计值 from " + bName + " where 时间='" + date + "' and 机组=" + unit + " and 班组=" + dtLevBZ.Rows[k][
                                                    "班组编号"].ToString() + " and 统计ID ='" + dtAvg.Rows[i]["统计ID"].ToString() + "'";
                                            else
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: 班组编号 || 统计ID 为空" + sql);

                                            objVal = DBsql.RunSingle(sql, out errMsg);

                                            if (objVal != null && objVal.ToString() != "")
                                            {
                                                if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(objVal.ToString(), num) + ",";
                                                }

                                                if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                                    if (dtAvg.Rows[i]["小数点数"].ToString() != "")
                                                        du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(objVal.ToString(), num) + ";";
                                                    else
                                                        du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + objVal.ToString() + ";";
                                                }
                                            }
                                            else
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: " + sql);
                                        }
                                    }
                                    #endregion

                                    #region 累计

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                                    DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtDiff != null && dtDiff.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtDiff.Rows.Count; i++)
                                        {
                                            num = dtDiff.Rows[i]["小数点数"].ToString();

                                            if (dtLevBZ.Rows[k]["班组编号"].ToString() != "" && dtDiff.Rows[i]["统计ID"].ToString() != "")
                                                sql = "select 统计值 from " + bName + " where 时间='" + date + "' and 机组=" + unit + " and 班组=" + dtLevBZ.Rows[k]["班组编号"].ToString() + " and 统计ID =                                            '" + dtDiff.Rows[i]["统计ID"].ToString() + "'";
                                            else
                                                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 平均 报程序异常: 班组编号 || 统计ID 为空" + sql);

                                            objVal = DBsql.RunSingle(sql, out errMsg);

                                            if (objVal != null && objVal.ToString() != "")
                                            {
                                                if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(objVal.ToString(), num) + ",";
                                                }

                                                if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                                    if (dtDiff.Rows[i]["小数点数"].ToString() != "")
                                                        du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(objVal.ToString(), num) + ";";
                                                    else
                                                        du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + objVal.ToString() + ";";
                                                }
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 电量
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtDL.Rows.Count > 0 && dtDL != null)
                                    {
                                        for (int i = 0; i < dtDL.Rows.Count; i++)
                                        {
                                            num = dtDL.Rows[i]["小数点数"].ToString();

                                            dlID = dtDL.Rows[i]["电量点"].ToString();

                                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                                            mon = "";
                                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                            res = "";
                                            try
                                            { res = StrHelper.Cale(mon); }
                                            catch
                                            { res = "0"; }

                                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(res, num) + ",";
                                            }

                                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                                if (dtDL.Rows[i]["小数点数"].ToString() != "")
                                                    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                                else
                                                    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            }
                                        }
                                    }

                                    #endregion

                                    #region SQL

                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                                    DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtSQL != null && dtSQL.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtSQL.Rows.Count; i++)
                                        {
                                            num = dtSQL.Rows[i]["小数点数"].ToString();

                                            sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                            if (sql.Contains("&BZ&"))
                                            {
                                                sql = sql.Replace("&BZ&", dtLevBZ.Rows[k]["班组编号"].ToString());
                                                sql = sql.Replace("&bt&", DateTime.Parse(qsrq).ToString("yyyy-MM-dd 0:00:00"));
                                                sql = sql.Replace("&et&", DateTime.Parse(jsrq).AddSeconds(-1).ToString());
                                            }
                                            else if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                            {
                                                sql = sql.Replace("&bt&", qsrq);
                                                sql = sql.Replace("&et&", DateTime.Parse(jsrq).AddSeconds(-1).ToString());
                                            }

                                            obj = DBsql.RunSingle(sql, out errMsg);

                                            res = "";
                                            if (obj != null && obj.ToString() != "")
                                            {
                                                if (obj.ToString() != "")
                                                    res = obj.ToString();
                                                else
                                                    res = "0";
                                            }
                                            else
                                            { res = "0"; }

                                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(res, num) + ",";
                                            }

                                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                                if (dtSQL.Rows[i]["小数点数"].ToString() != "")
                                                    du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                                else
                                                    du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            }
                                        }
                                    }
                                    #endregion

                                    #region 其它
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtQT.Rows.Count > 0 && dtQT != null)
                                    {
                                        for (int i = 0; i < dtQT.Rows.Count; i++)
                                        {
                                            num = dtQT.Rows[i]["小数点数"].ToString();

                                            #region 购网电量
                                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                            {
                                                string re = um.gwdl(qsrq, jsrq, unit);

                                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";
                                                }

                                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re + ";";
                                                }
                                            }
                                            #endregion

                                            #region 入炉煤低位发热量
                                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                            {
                                                string rlm = um.rlmdwfrl("值报", qsrq, jsrq, 1);

                                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(rlm, num) + ",";
                                                }

                                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                    if (dtQT.Rows[i]["小数点数"].ToString() != "")
                                                        du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                                    else
                                                        du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                                }
                                            }
                                            #endregion
                                        }
                                    }
                                    #endregion

                                    #region 公式
                                    sql = "select * from T_sheet_ZsheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                                    if (dtMon != null && dtMon.Rows.Count > 0)
                                    {
                                        for (int i = 0; i < dtMon.Rows.Count; i++)
                                        {
                                            num = dtMon.Rows[i]["小数点数"].ToString();

                                            string pMon = dtMon.Rows[i]["公式"].ToString();

                                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                                            string month = pm.retMon(pMon, paras, du, a.ToString());

                                            if (month != "")
                                            {
                                                res = "";
                                                try
                                                {
                                                    res = StrHelper.Cale(month);
                                                    res = sh.ShowPoint(res, num);
                                                }
                                                catch
                                                {
                                                    res = "0";
                                                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日值 公式 报程序异常: " + pMon + ":" + paras + ":" + month);
                                                }

                                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                                {
                                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                                    dv[id] += sh.ShowPoint(res, num) + ",";
                                                }

                                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                                {
                                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                                    if (dtMon.Rows[i]["小数点数"].ToString() != "")
                                                        du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                                    else
                                                        du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                                }
                                            }
                                        }
                                    }

                                    #endregion
                                }
                            }
                            a++;
                        }
                    }
                }
            }
            catch (Exception ce)
            { LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);

            return list;
        }

        /// <summary>
        /// 日报
        /// 机组轮转
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="qsrq"></param>
        /// <param name="jsrq"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepDay(string repName, string repType, string qsrq, string jsrq, bool isDay)
        {
            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string unit = "";
            string pName = "";
            string dlID = "";

            int ret = 0;
            int id;
            object obj;
            double drvA = 0;
            double drvB = 0;

            //基础数据值
            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] dvExcel = null;

            string sDate = "";

            if (isDay == true)
                sDate = DateTime.Parse(jsrq).ToString("yyyy-MM-dd H:59:59");
            else
                sDate = DateTime.Parse(jsrq).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 1);
            countKey = pm.GetCountkey(repName, 1);

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            //try
            //{
            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];

            dvExcel = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

            //机组数据轮转
            sql = "SELECT DISTINCT 机组 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0";

            DataTable dtLevUnit = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevUnit != null && dtLevUnit.Rows.Count > 0)
            {
                for (int k = 0; k < dtLevUnit.Rows.Count; k++)
                {
                    unit = dtLevUnit.Rows[k]["机组"].ToString();

                    sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0 and 公式级别!=0";

                    DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                    if (dtLel.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtLel.Rows.Count; j++)
                        {
                            string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                            #region 平均
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                            DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                            if (dtAvg != null && dtAvg.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtAvg.Rows.Count; i++)
                                {
                                    num = dtAvg.Rows[i]["小数点数"].ToString();

                                    pName = dtAvg.Rows[i][repType].ToString();

                                    ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                                    if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                        //if (dtAvg.Rows[i]["小数点数"].ToString() != "")
                                        //du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                        //else
                                        du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 累计
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                            DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDiff != null && dtDiff.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtDiff.Rows.Count; i++)
                                {
                                    num = dtDiff.Rows[i]["小数点数"].ToString();

                                    pName = dtDiff.Rows[i][repType].ToString();

                                    ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                                    if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                        //if (dtDiff.Rows[i]["小数点数"].ToString() != "")
                                        //du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                        //else
                                        du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                    }
                                }
                            }

                            #endregion

                            #region SQL

                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                            DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtSQL != null && dtSQL.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtSQL.Rows.Count; i++)
                                {
                                    num = dtSQL.Rows[i]["小数点数"].ToString();

                                    sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                    if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                    {
                                        sql = sql.Replace("&bt&", qsrq);
                                        sql = sql.Replace("&et&", sDate);
                                    }

                                    obj = DBsql.RunSingle(sql, out errMsg);

                                    res = "";
                                    if (obj != null && obj != "")
                                    {
                                        if (obj.ToString() != "")
                                            res = obj.ToString();
                                        else
                                            res = "0";
                                    }
                                    else
                                    { res = "0"; }

                                    if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                        //if (dtSQL.Rows[i]["小数点数"].ToString() != "")
                                        //du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        //else
                                        du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 电量
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                            DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDL.Rows.Count > 0 && dtDL != null)
                            {
                                for (int i = 0; i < dtDL.Rows.Count; i++)
                                {
                                    num = dtDL.Rows[i]["小数点数"].ToString();

                                    dlID = dtDL.Rows[i]["电量点"].ToString();

                                    drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                                    mon = "";
                                    mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (dtDL.Rows[i]["小数点数"].ToString() != "")
                                        //du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        //else
                                        du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                    }
                                }
                            }

                            #endregion

                            #region 其它
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                            DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                            if (dtQT.Rows.Count > 0 && dtQT != null)
                            {
                                for (int i = 0; i < dtQT.Rows.Count; i++)
                                {
                                    num = dtQT.Rows[i]["小数点数"].ToString();

                                    #region 购网电量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                    {
                                        string re = um.gwdl(qsrq, jsrq, int.Parse(unit));

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                            dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re + ";";
                                        }
                                    }
                                    #endregion
                                    //
                                    #region 入炉煤低位发热量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                    {
                                        string rlm = um.rlmdwfrl("日报", qsrq, jsrq, 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(rlm, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (dtQT.Rows[i]["小数点数"].ToString() != "")
                                            //du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                            //else
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                        }
                                    }
                                    #endregion

                                    #region K2(q2)
                                    if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                    {
                                        string pid = dtQT.Rows[i]["参数ID"].ToString();

                                        string val = um.K2(pid, du, int.Parse(unit));

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(val, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            #region 公式
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                            DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                            if (dtMon != null && dtMon.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtMon.Rows.Count; i++)
                                {
                                    num = dtMon.Rows[i]["小数点数"].ToString();

                                    string pMon = dtMon.Rows[i]["公式"].ToString();

                                    string paras = dtMon.Rows[i]["公式参数"].ToString();

                                    string month = pm.retMon(pMon, paras, du, unit);

                                    if (month != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(month);

                                            if (dtMon.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            }

                                            if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                                du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                            }

                                            res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(res, num) + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (dtMon.Rows[i]["小数点数"].ToString() != "")
                                            //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                            //else
                                            //du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        }
                                    }
                                }
                            }

                            #endregion


                        }
                    }
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取机组信息失败......");


            //全厂数据
            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 公式级别!=0";

            DataTable dtLevZ = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevZ.Rows.Count > 0)
            {
                for (int j = 0; j < dtLevZ.Rows.Count; j++)
                {
                    string gsjb = dtLevZ.Rows[j]["公式级别"].ToString();

                    #region 平均
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='平均' and 公式级别=" + gsjb;

                    DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                    if (dtAvg != null && dtAvg.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtAvg.Rows.Count; i++)
                        {
                            num = dtAvg.Rows[i]["小数点数"].ToString();

                            pName = dtAvg.Rows[i][repType].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                            if (dtAvg.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                            }

                            if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                //if (num != "")
                                //    du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                //else
                                du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                            }
                        }
                    }
                    #endregion

                    #region 累计
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='累计' and 公式级别=" + gsjb;

                    DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDiff != null && dtDiff.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtDiff.Rows.Count; i++)
                        {
                            num = dtDiff.Rows[i]["小数点数"].ToString();

                            pName = dtDiff.Rows[i][repType].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                            if (dtDiff.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                            }

                            if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                //if (num != "")
                                //    du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                //else
                                du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                            }
                        }
                    }

                    #endregion

                    #region SQL

                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='SQL' and 公式级别=" + gsjb;

                    DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtSQL != null && dtSQL.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtSQL.Rows.Count; i++)
                        {
                            num = dtSQL.Rows[i]["小数点数"].ToString();

                            sql = dtSQL.Rows[i]["SQL语句"].ToString();

                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                            {
                                sql = sql.Replace("&bt&", qsrq);
                                sql = sql.Replace("&et&", sDate);
                            }

                            obj = DBsql.RunSingle(sql, out errMsg);

                            res = "";
                            if (obj != null && obj != "")
                            {
                                if (obj.ToString() != "")
                                    res = obj.ToString();
                                else
                                    res = "0";
                            }
                            else
                            { res = "0"; }

                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                //if (num != "")
                                //    du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                //else
                                du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                            }
                        }
                    }
                    #endregion

                    #region 电量
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='电量' and 公式级别=" + gsjb;

                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDL.Rows.Count > 0 && dtDL != null)
                    {
                        for (int i = 0; i < dtDL.Rows.Count; i++)
                        {
                            num = dtDL.Rows[i]["小数点数"].ToString();

                            dlID = dtDL.Rows[i]["电量点"].ToString();

                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                            mon = "";
                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num != "")
                                //    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                //else
                                du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                            }
                        }
                    }

                    #endregion

                    #region 其它
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='其它' and 公式级别=" + gsjb;

                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                    if (dtQT.Rows.Count > 0 && dtQT != null)
                    {
                        for (int i = 0; i < dtQT.Rows.Count; i++)
                        {
                            num = dtQT.Rows[i]["小数点数"].ToString();

                            #region 购网电量
                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                            {
                                string re = um.gwdl(qsrq, jsrq, 0);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                    dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                }
                            }
                            #endregion

                            #region 入炉煤低位发热量
                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                            {
                                string rlm = um.rlmdwfrl("日报", qsrq, jsrq, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(rlm, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num != "")
                                    //    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                    //else
                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                }
                            }
                            #endregion

                            #region K2(q2)
                            if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                            {
                                string pid = dtQT.Rows[i]["参数ID"].ToString();

                                string val = um.K2(pid, du, 0);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(val, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 公式
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='公式' and 公式级别=" + gsjb;

                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                    if (dtMon != null && dtMon.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtMon.Rows.Count; i++)
                        {
                            num = dtMon.Rows[i]["小数点数"].ToString();

                            string pMon = dtMon.Rows[i]["公式"].ToString();

                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                            string month = pm.retMon(pMon, paras, du);

                            if (month != "")
                            {
                                res = "";
                                try
                                { res = StrHelper.Cale(month); }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                }
                            }
                        }
                    }
                    #endregion
                }
            }
            //}
            //catch (Exception ce)
            //{ LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            for (int i = 1; i < du.Length; i++)
            {
                LogHelper.WriteLog(LogHelper.EnLogType.Success, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + du[i].ToString());
            }

            for (int i = 1; i < dv.Length; i++)
            {
                LogHelper.WriteLog(LogHelper.EnLogType.Warn, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + dv[i].ToString());
            }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvExcel);

            return list;
        }

        /// <summary>
        /// 月、季、年报表
        /// 机组轮转
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="pType"></param>
        /// <param name="qsrq"></param>
        /// <param name="jsrq"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepMonth(string repName, string repType, string pType, string qsrq, string jsrq, string qsrqT, string jsrqT, bool isDay)
        {
            int id;
            object obj;
            int ret = 0;
            double drvA = 0;
            double drvB = 0;

            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string unit = "";
            string pName = "";
            string dlID = "";

            //基础数据值
            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] dvT = null;
            string[] duT = null;

            string[] dvExcel = null;
            string[] dvExcelT = null;

            string sDate = "";

            if (isDay == true)
                //sDate = DateTime.Parse(jsrq).ToString("yyyy-MM-dd H:59:59");
                sDate = DateTime.Parse(jsrq).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");
            else
                sDate = DateTime.Parse(jsrq).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

            string sDateT = DateTime.Parse(jsrqT).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 1);
            countKey = pm.GetCountkey(repName, 1);

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            //try
            //{
            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];
            dvT = new string[count + 1];
            duT = new string[countKey + 1];

            dvExcel = new string[count + 1];
            dvExcelT = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

            //机组数据轮转
            sql = "SELECT DISTINCT 机组 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0";

            DataTable dtLevUnit = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevUnit != null && dtLevUnit.Rows.Count > 0)
            {
                for (int k = 0; k < dtLevUnit.Rows.Count; k++)
                {
                    unit = dtLevUnit.Rows[k]["机组"].ToString();

                    sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0 and 公式级别!=0";

                    DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                    if (dtLel.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtLel.Rows.Count; j++)
                        {
                            string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                            #region 平均
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                            DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                            if (dtAvg != null && dtAvg.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtAvg.Rows.Count; i++)
                                {
                                    num = dtAvg.Rows[i]["小数点数"].ToString();

                                    pName = dtAvg.Rows[i][pType].ToString();

                                    ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    ek.GetHisValueByTime(pName, sDateT, ref ret, ref drvB);

                                    if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";
                                        dvT[id] += sh.ShowPoint(drvB.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                        dvExcelT[id] += drvB.ToString() + ",";
                                    }

                                    if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        //{
                                        du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        duT[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvB.ToString() + ";";
                                        //}
                                        //else
                                        //{
                                        //    du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                        //    duT[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvB.ToString(), num) + ";";
                                        //}
                                    }
                                }
                            }
                            #endregion

                            #region 累计
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                            DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDiff != null && dtDiff.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtDiff.Rows.Count; i++)
                                {
                                    num = dtDiff.Rows[i]["小数点数"].ToString();

                                    pName = dtDiff.Rows[i][pType].ToString();

                                    ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    ek.GetHisValueByTime(pName, sDateT, ref ret, ref drvB);

                                    if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";
                                        dvT[id] += sh.ShowPoint(drvB.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                        dvExcelT[id] += drvB.ToString() + ",";
                                    }

                                    if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        //{
                                        du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        duT[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvB.ToString() + ";";
                                        //}
                                        //else
                                        //{
                                        //    du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                        //    duT[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvB.ToString(), num) + ";";
                                        //}
                                    }
                                }
                            }

                            #endregion

                            #region SQL

                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                            DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtSQL != null && dtSQL.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtSQL.Rows.Count; i++)
                                {
                                    num = dtSQL.Rows[i]["小数点数"].ToString();

                                    //本期
                                    sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                    if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                    {
                                        sql = sql.Replace("&bt&", qsrq);
                                        sql = sql.Replace("&et&", sDate);
                                    }

                                    obj = DBsql.RunSingle(sql, out errMsg);

                                    res = "";
                                    if (obj != null && obj != "")
                                    {
                                        if (obj.ToString() != "")
                                            res = obj.ToString();
                                        else
                                            res = "0";
                                    }
                                    else
                                    { res = "0"; }

                                    if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }

                                    //同期
                                    sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                    if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                    {
                                        sql = sql.Replace("&bt&", qsrqT);
                                        sql = sql.Replace("&et&", sDateT);
                                    }

                                    obj = DBsql.RunSingle(sql, out errMsg);

                                    res = "";
                                    if (obj != null && obj != "")
                                    {
                                        if (obj.ToString() != "")
                                            res = obj.ToString();
                                        else
                                            res = "0";
                                    }
                                    else
                                    { res = "0"; }

                                    if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                        dvT[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        duT[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    duT[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 电量
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                            DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDL.Rows.Count > 0 && dtDL != null)
                            {
                                for (int i = 0; i < dtDL.Rows.Count; i++)
                                {
                                    num = dtDL.Rows[i]["小数点数"].ToString();

                                    dlID = dtDL.Rows[i]["电量点"].ToString();

                                    drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                                    mon = "";
                                    mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }

                                    drvB = double.Parse(pc.GetPower(drvB, dlID, qsrqT, jsrqT, bm).ToString());

                                    mon = "";
                                    mon = drvB.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dvT[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region 其它
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                            DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                            if (dtQT.Rows.Count > 0 && dtQT != null)
                            {
                                for (int i = 0; i < dtQT.Rows.Count; i++)
                                {
                                    num = dtQT.Rows[i]["小数点数"].ToString();

                                    #region 购网电量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                    {
                                        string re = um.gwdl(qsrq, jsrq, int.Parse(unit), "mx");

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                            dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                        }

                                        //同期
                                        string reT = um.gwdl(qsrqT, jsrqT, int.Parse(unit), "mx");

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                        }

                                    }
                                    #endregion

                                    #region 入炉煤低位发热量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                    {
                                        string rlm = um.rlmdwfrl("月报", qsrq, jsrq, 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(rlm, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                            //else
                                            //  du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                        }

                                        string rlmT = um.rlmdwfrl(repType, qsrqT, jsrqT, 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                            //else
                                            //    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlmT, num) + ";";
                                        }
                                    }
                                    #endregion

                                    #region K2(q2)
                                    if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                    {
                                        string pid = dtQT.Rows[i]["参数ID"].ToString();

                                        string val = "0";
                                        string valT = "0";

                                        val = um.K2(pid, du, int.Parse(unit));
                                        valT = um.K2(pid, duT, int.Parse(unit));

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(val, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                            dvT[id] += sh.ShowPoint(valT.ToString(), num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(valT.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + valT.ToString() + ";";
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            #region 公式
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                            DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                            if (dtMon != null && dtMon.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtMon.Rows.Count; i++)
                                {
                                    num = dtMon.Rows[i]["小数点数"].ToString();

                                    string pMon = dtMon.Rows[i]["公式"].ToString();

                                    string paras = dtMon.Rows[i]["公式参数"].ToString();

                                    string month = pm.retMon(pMon, paras, du, unit);
                                    string monthT = pm.retMon(pMon, paras, duT, unit);

                                    if (month != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(month);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(res, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                            //else
                                            //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        }
                                    }

                                    if (monthT != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(monthT);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(res, num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            //else
                                            //    duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取机组信息失败......");

            //全厂数据
            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 公式级别!=0";

            DataTable dtLevZ = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevZ.Rows.Count > 0)
            {
                for (int j = 0; j < dtLevZ.Rows.Count; j++)
                {
                    string gsjb = dtLevZ.Rows[j]["公式级别"].ToString();

                    #region 平均
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='平均' and 公式级别=" + gsjb;

                    DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                    if (dtAvg != null && dtAvg.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtAvg.Rows.Count; i++)
                        {
                            num = dtAvg.Rows[i]["小数点数"].ToString();

                            pName = dtAvg.Rows[i][pType].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                            ek.GetHisValueByTime(pName, sDateT, ref ret, ref drvB);

                            if (dtAvg.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";
                                dvT[id] += sh.ShowPoint(drvB.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                                dvExcelT[id] += drvB.ToString() + ",";
                            }

                            if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                //{
                                du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                duT[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + drvB.ToString() + ";";
                                //}
                                //else
                                //{
                                //    du[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                //    duT[id] += dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvB.ToString(), num) + ";";
                                //}
                            }
                        }
                    }
                    #endregion

                    #region 累计
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='累计' and 公式级别=" + gsjb;

                    DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDiff != null && dtDiff.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtDiff.Rows.Count; i++)
                        {
                            num = dtDiff.Rows[i]["小数点数"].ToString();

                            pName = dtDiff.Rows[i][pType].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                            ek.GetHisValueByTime(pName, sDateT, ref ret, ref drvB);

                            if (dtDiff.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";
                                dvT[id] += sh.ShowPoint(drvB.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                                dvExcelT[id] += drvB.ToString() + ",";
                            }

                            if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                //{
                                du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                duT[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + drvB.ToString() + ";";
                                //}
                                //else
                                //{
                                //    du[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                //    duT[id] += dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvB.ToString(), num) + ";";
                                //}
                            }
                        }
                    }

                    #endregion

                    #region SQL

                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='SQL' and 公式级别=" + gsjb;

                    DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtSQL != null && dtSQL.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtSQL.Rows.Count; i++)
                        {
                            num = dtSQL.Rows[i]["小数点数"].ToString();

                            //本期
                            sql = dtSQL.Rows[i]["SQL语句"].ToString();

                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                            {
                                sql = sql.Replace("&bt&", qsrq);
                                sql = sql.Replace("&et&", sDate);
                            }

                            obj = DBsql.RunSingle(sql, out errMsg);

                            res = "";
                            if (obj != null && obj != "")
                            {
                                if (obj.ToString() != "")
                                    res = obj.ToString();
                                else
                                    res = "0";
                            }
                            else
                            { res = "0"; }

                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    du[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }

                            //同期
                            sql = dtSQL.Rows[i]["SQL语句"].ToString();

                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                            {
                                sql = sql.Replace("&bt&", qsrqT);
                                sql = sql.Replace("&et&", sDateT);
                            }

                            obj = DBsql.RunSingle(sql, out errMsg);

                            res = "";
                            if (obj != null && obj != "")
                            {
                                if (obj.ToString() != "")
                                    res = obj.ToString();
                                else
                                    res = "0";
                            }
                            else
                            { res = "0"; }

                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                dvT[id] += sh.ShowPoint(res, num) + ",";

                                dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                duT[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    duT[id] += dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }
                        }
                    }
                    #endregion

                    #region 电量
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='电量' and 公式级别=" + gsjb;

                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDL.Rows.Count > 0 && dtDL != null)
                    {
                        for (int i = 0; i < dtDL.Rows.Count; i++)
                        {
                            num = dtDL.Rows[i]["小数点数"].ToString();

                            dlID = dtDL.Rows[i]["电量点"].ToString();

                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                            mon = "";
                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }

                            drvB = double.Parse(pc.GetPower(drvB, dlID, qsrqT, jsrqT, bm).ToString());

                            mon = "";
                            mon = drvB.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dvT[id] += sh.ShowPoint(res, num) + ",";

                                dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }
                        }
                    }

                    #endregion

                    #region 其它
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='其它' and 公式级别=" + gsjb;

                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                    if (dtQT.Rows.Count > 0 && dtQT != null)
                    {
                        for (int i = 0; i < dtQT.Rows.Count; i++)
                        {
                            num = dtQT.Rows[i]["小数点数"].ToString();

                            #region 购网电量
                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                            {
                                string re = um.gwdl(qsrq, jsrq, 0, "mx");

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                    dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                }

                                string reT = um.gwdl(qsrqT, jsrqT, 0, "mx");

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                }

                            }
                            #endregion

                            #region 入炉煤低位发热量
                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                            {
                                string rlm = um.rlmdwfrl("月报", qsrq, jsrq, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(rlm, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                    //else
                                    //    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                }

                                string rlmT = um.rlmdwfrl(repType, qsrqT, jsrqT, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                    //else
                                    //    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlmT, num) + ";";
                                }
                            }
                            #endregion

                            #region K2(q2)
                            if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                            {
                                string pid = dtQT.Rows[i]["参数ID"].ToString();

                                string val = "0";
                                string valT = "0";

                                val = um.K2(pid, du, 0);
                                valT = um.K2(pid, duT, 0);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(val, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                    dvT[id] += sh.ShowPoint(valT.ToString(), num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(valT.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + valT.ToString() + ";";
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 公式
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='公式' and 公式级别=" + gsjb;

                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                    if (dtMon != null && dtMon.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtMon.Rows.Count; i++)
                        {
                            num = dtMon.Rows[i]["小数点数"].ToString();

                            string pMon = dtMon.Rows[i]["公式"].ToString();

                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                            string month = pm.retMon(pMon, paras, du);
                            string monthT = pm.retMon(pMon, paras, duT);

                            if (month != "")
                            {
                                res = "";
                                try
                                {
                                    res = StrHelper.Cale(month);
                                    //res = sh.ShowPoint(res, num);
                                }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";
                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                }
                            }

                            if (monthT != "")
                            {
                                res = "";
                                try
                                {
                                    res = StrHelper.Cale(monthT);
                                    //res = sh.ShowPoint(res, num);
                                }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(res, num) + ",";
                                    dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //  duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                }
                            }
                        }
                    }

                    #endregion
                }
            }

            //}
            //catch (Exception ce)
            //{ LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            for (int i = 1; i < du.Length; i++)
            {
                if (du[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Success, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + du[i].ToString());
            }

            for (int i = 1; i < dv.Length; i++)
            {
                if (dv[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Warn, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + dv[i].ToString());
            }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvT);
            list.Add(dvExcel);
            list.Add(dvExcelT);

            return list;
        }

        /// <summary>
        /// 月明细报表
        /// 机组轮转
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="date"></param>
        /// <param name="isDay"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepMonthInfo(string repName, int unit, DateTime date, int isDay)
        {
            int days;
            string fDay = "";
            string lDay = "";
            int id;
            object obj;
            int ret = 0;
            double drvA = 0;
            double drvB = 0;
            string sDate = "";

            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string pName = "";
            string dlID = "";

            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] qsrq = null;
            string[] jsrq = null;

            string[] dvExcel = null;

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 2);
            countKey = pm.GetCountkey(repName, 2);

            days = DateTime.DaysInMonth(date.Year, date.Month);

            #region 日期
            if (isDay == 0)
            {
                qsrq = new string[days + 1];
                jsrq = new string[days + 1];

                for (int i = 1; i < DateTime.Now.Day; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");
            }
            else
            {
                qsrq = new string[days + 1];
                jsrq = new string[days + 1];

                for (int i = 1; i < days + 1; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = jsrq[days];
            }

            #endregion

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            //try
            //{
            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];

            dvExcel = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");


            for (int k = 1; k <= 31; k++)
            {
                if (k < qsrq.Length)
                {
                    if (qsrq[k] != null)
                        sDate = DateTime.Parse(qsrq[k]).ToString("yyyy-MM-dd 23:59:59");

                    sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

                    DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                    if (dtLel.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtLel.Rows.Count; j++)
                        {
                            string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                            #region 平均
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                            DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                            if (dtAvg != null && dtAvg.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtAvg.Rows.Count; i++)
                                {
                                    num = dtAvg.Rows[i]["小数点数"].ToString();

                                    pName = dtAvg.Rows[i]["日点"].ToString();

                                    if (qsrq[k] != null)
                                        ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    else
                                        drvA = 0;

                                    if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        //else
                                        //    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 累计
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                            DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDiff != null && dtDiff.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtDiff.Rows.Count; i++)
                                {
                                    num = dtDiff.Rows[i]["小数点数"].ToString();

                                    pName = dtDiff.Rows[i]["日点"].ToString();

                                    drvA = 0;
                                    if (qsrq[k] != null)
                                        ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    else
                                        drvA = 0;

                                    if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        //else
                                        //    du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region SQL

                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                            DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtSQL != null && dtSQL.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtSQL.Rows.Count; i++)
                                {
                                    num = dtSQL.Rows[i]["小数点数"].ToString();

                                    sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                    if (qsrq[k] != null)
                                    {
                                        if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                        {
                                            sql = sql.Replace("&bt&", qsrq[k].ToString());
                                            sql = sql.Replace("&et&", sDate);
                                        }

                                        obj = DBsql.RunSingle(sql, out errMsg);

                                        res = "";
                                        if (obj != null && obj != "")
                                        {
                                            if (obj.ToString() != "")
                                                res = obj.ToString();
                                            else
                                                res = "0";
                                        }
                                        else
                                        { res = "0"; }
                                    }
                                    else
                                        res = "0";

                                    if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 电量
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                            DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDL.Rows.Count > 0 && dtDL != null)
                            {
                                for (int i = 0; i < dtDL.Rows.Count; i++)
                                {
                                    num = dtDL.Rows[i]["小数点数"].ToString();

                                    dlID = dtDL.Rows[i]["电量点"].ToString();

                                    if (qsrq[k] != null)
                                        drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq[k], jsrq[k], bm).ToString());
                                    else
                                        drvA = 0;

                                    mon = "";
                                    mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region 其它
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                            DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                            if (dtQT.Rows.Count > 0 && dtQT != null)
                            {
                                for (int i = 0; i < dtQT.Rows.Count; i++)
                                {
                                    num = dtQT.Rows[i]["小数点数"].ToString();

                                    #region 购网电量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                    {
                                        string re = "0";

                                        if (qsrq[k] != null)
                                            re = um.gwdl(qsrq[k].ToString(), jsrq[k].ToString(), unit);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                            dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                        }
                                    }
                                    #endregion

                                    #region 入炉煤低位发热量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                    {
                                        string rlm = um.rlmdwfrl("日报", qsrq[k], jsrq[k], 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(rlm, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                            //else
                                            //    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                        }
                                    }
                                    #endregion

                                    #region K2(q2)
                                    if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                    {
                                        string pid = dtQT.Rows[i]["参数ID"].ToString();

                                        string val = um.K2(pid, du, unit);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(val, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            #region 公式
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                            DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                            if (dtMon != null && dtMon.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtMon.Rows.Count; i++)
                                {
                                    num = dtMon.Rows[i]["小数点数"].ToString();

                                    string pMon = dtMon.Rows[i]["公式"].ToString();

                                    string paras = dtMon.Rows[i]["公式参数"].ToString();

                                    string month = pm.retMon(pMon, paras, du);

                                    if (month != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(month);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            if (qsrq[k] != null)
                                                dv[id] += sh.ShowPoint(res, num) + ",";
                                            else
                                                dv[id] += sh.ShowPoint("0", num) + ",";

                                            if (qsrq[k] != null)
                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            else
                                                dvExcel[id] += "0" + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            //else
                                            du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                    else
                        LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报表,日值部分,公式级别读取失败......");
                }
            }

            //月累计
            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

            DataTable dtLelMonth = DBsql.RunDataTable(sql, out errMsg);

            if (dtLelMonth.Rows.Count > 0)
            {
                if (isDay == 0)
                    sDate = DateTime.Parse(lDay).AddSeconds(-1).ToString("yyyy-MM-dd 23:59:59");
                else
                    sDate = DateTime.Parse(lDay).AddSeconds(-1).ToString("yyyy-MM-dd 23:59:59");

                for (int j = 0; j < dtLelMonth.Rows.Count; j++)
                {
                    string gsjb = dtLelMonth.Rows[j]["公式级别"].ToString();

                    #region 平均
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                    DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                    if (dtAvg != null && dtAvg.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtAvg.Rows.Count; i++)
                        {
                            num = dtAvg.Rows[i]["小数点数"].ToString();

                            pName = dtAvg.Rows[i]["月点"].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                            if (dtAvg.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                            }

                            if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                //else
                                //    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                            }
                        }
                    }
                    #endregion

                    #region 累计
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                    DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDiff != null && dtDiff.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtDiff.Rows.Count; i++)
                        {
                            num = dtDiff.Rows[i]["小数点数"].ToString();

                            pName = dtDiff.Rows[i]["月点"].ToString();

                            ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);

                            if (dtDiff.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                            }

                            if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                //else
                                //    du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                            }
                        }
                    }

                    #endregion

                    #region SQL

                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                    DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtSQL != null && dtSQL.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtSQL.Rows.Count; i++)
                        {
                            num = dtSQL.Rows[i]["小数点数"].ToString();

                            sql = dtSQL.Rows[i]["SQL语句"].ToString();


                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                            {
                                sql = sql.Replace("&bt&", fDay);
                                sql = sql.Replace("&et&", sDate);
                            }

                            obj = DBsql.RunSingle(sql, out errMsg);

                            res = "";
                            if (obj != null && obj != "")
                            {
                                if (obj.ToString() != "")
                                    res = obj.ToString();
                                else
                                    res = "0";
                            }
                            else
                            { res = "0"; }


                            if (dtSQL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                //du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                            }
                        }
                    }
                    #endregion

                    #region 电量
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDL.Rows.Count > 0 && dtDL != null)
                    {
                        for (int i = 0; i < dtDL.Rows.Count; i++)
                        {
                            num = dtDL.Rows[i]["小数点数"].ToString();

                            dlID = dtDL.Rows[i]["电量点"].ToString();

                            drvA = double.Parse(pc.GetPower(drvA, dlID, fDay, lDay, bm).ToString());

                            mon = "";
                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                //du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                            }
                        }
                    }

                    #endregion

                    #region 其它
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                    if (dtQT.Rows.Count > 0 && dtQT != null)
                    {
                        for (int i = 0; i < dtQT.Rows.Count; i++)
                        {
                            num = dtQT.Rows[i]["小数点数"].ToString();

                            #region 购网电量
                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                            {
                                string re = um.gwdl(fDay, lDay, unit, "mx");

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                    dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                }
                            }
                            #endregion

                            #region 入炉煤低位发热量
                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                            {
                                string rlm = um.rlmdwfrl("月报", fDay, lDay, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(rlm, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                    //else
                                    //    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                }
                            }
                            #endregion

                            #region K2(q2)
                            if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                            {
                                string pid = dtQT.Rows[i]["参数ID"].ToString();

                                string val = um.K2(pid, du, 0);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(val, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 公式
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                    if (dtMon != null && dtMon.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtMon.Rows.Count; i++)
                        {
                            num = dtMon.Rows[i]["小数点数"].ToString();

                            string pMon = dtMon.Rows[i]["公式"].ToString();

                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                            string month = pm.retMon(pMon, paras, du);

                            if (month != "")
                            {
                                res = "";
                                try
                                {
                                    res = StrHelper.Cale(month);
                                    //res = sh.ShowPoint(res, num);
                                }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //    du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                }
                            }
                        }
                    }

                    #endregion
                }


            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报表,月值部分,公式级别读取失败......");


            //}
            //catch (Exception ce)
            //{ LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            for (int i = 1; i < du.Length; i++)
            {
                if (du[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Success, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + du[i].ToString());
            }

            for (int i = 1; i < dv.Length; i++)
            {
                if (dv[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Warn, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + dv[i].ToString());
            }


            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvExcel);

            return list;
        }

        /// <summary>
        /// 年明细报表
        /// 机组轮转
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="unit"></param>
        /// <param name="date"></param>
        /// <param name="isDay"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepYearInfo(string repName, int unit, DateTime date, int isDay)
        {
            int id;
            object obj;
            int ret = 0;
            double drvA = 0;
            double drvAT = 0;

            string bm = "";
            string mon = "";
            string res = "";
            string resT = "";
            string num = "";
            string pName = "";
            string dlID = "";
            string sDate1 = "";
            string sDate1T = "";

            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] zy = null;     //最优值描述
            string[] zyB = null;    //最优本期
            string[] zyT = null;    //最优同期

            string[] dv = null;
            string[] du = null;
            string[] dvT = null;
            string[] duT = null;

            string[] dvExcel = null;
            string[] dvExcelT = null;

            string[] qsrq = new string[12];
            string[] jsrq = new string[12];
            string[] sDate = new string[12];

            string[] qsrqT = new string[12];
            string[] jsrqT = new string[12];
            string[] sDateT = new string[12];

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 2);
            countKey = pm.GetCountkey(repName, 2);

            #region 日期
            //本期时间
            if (isDay == 0)
            {
                for (int i = 0; i < DateTime.Now.Month; i++)
                {
                    qsrq[i] = date.AddMonths(+i).ToString("yyyy-MM-dd H:mm:ss");
                    jsrq[i] = date.AddMonths(+i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");
                    sDate[i] = date.AddMonths(+i).AddMonths(+1).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

                    if (DateTime.Parse(qsrq[i]).Month == DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 0:00:00")).Month)
                    {
                        jsrq[i] = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");//DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd")
                        sDate[i] = DateTime.Parse(DateTime.Now.ToString("yyyy-MM-dd 0:00:00")).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");
                    }

                    sDate[11] = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");

                }
            }
            else
            {
                for (int i = 0; i < 12; i++)
                {
                    qsrq[i] = date.AddMonths(+i).ToString("yyyy-MM-dd H:mm:ss");
                    jsrq[i] = date.AddMonths(+i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");
                    sDate[i] = date.AddMonths(+i).AddMonths(+1).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");
                }
            }
            DateTime dtT = DateTime.Parse(qsrq[0]).AddYears(-1);

            //同期时间
            for (int i = 0; i < 12; i++)
            {
                qsrqT[i] = dtT.AddMonths(i).ToString("yyyy-MM-dd H:mm:ss");
                jsrqT[i] = dtT.AddMonths(i).AddMonths(+1).ToString("yyyy-MM-dd H:mm:ss");
                sDateT[i] = dtT.AddMonths(i).AddMonths(+1).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");
            }
            #endregion

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 年明细报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            try
            {
                zb = new string[count + 1];
                un = new string[count + 1];
                lay = new string[count + 1];
                zy = new string[count + 1];     //最优值描述
                zyB = new string[count + 1];    //最优本期
                zyT = new string[count + 1];    //最优同期

                dv = new string[count + 1];
                du = new string[countKey + 1];
                dvT = new string[count + 1];
                duT = new string[countKey + 1];

                dvExcel = new string[count + 1];
                dvExcelT = new string[count + 1];

                string[] zyDu = new string[count + 1];
                string[] zyDuT = new string[count + 1];

                //直接取出中文描速,单位,设计值
                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数顺序!=0 order by 参数顺序";

                DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

                if (dtInfo != null && dtInfo.Rows.Count > 0)
                {
                    for (int k = 0; k < dtInfo.Rows.Count; k++)
                    {
                        id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                        zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                        un[id] = dtInfo.Rows[k]["单位"].ToString();
                        lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                        zy[id] = dtInfo.Rows[k]["最优值"].ToString();
                    }
                }
                else
                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

                #region 月数据
                for (int k = 0; k < 12; k++)
                {
                    if (k < qsrq.Length)
                    {
                        if (qsrq[k] != null)
                            sDate1 = DateTime.Parse(jsrq[k]).AddSeconds(-1).ToString("yyyy-MM-dd 23:59:59");

                        if (qsrqT[k] != null)
                            sDate1T = DateTime.Parse(jsrqT[k]).AddSeconds(-1).ToString("yyyy-MM-dd 23:59:59");

                        sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

                        DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                        if (dtLel.Rows.Count > 0)
                        {
                            for (int j = 0; j < dtLel.Rows.Count; j++)
                            {
                                string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                                #region 平均
                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                                DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                                if (dtAvg != null && dtAvg.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dtAvg.Rows.Count; i++)
                                    {
                                        num = dtAvg.Rows[i]["小数点数"].ToString();

                                        pName = dtAvg.Rows[i]["月点"].ToString();

                                        if (qsrq[k] != null)
                                            ek.GetHisValueByTime(pName, sDate1, ref ret, ref drvA);
                                        else
                                            drvA = 0;

                                        if (qsrqT[k] != null)
                                            ek.GetHisValueByTime(pName, sDate1T, ref ret, ref drvAT);
                                        else
                                            drvAT = 0;

                                        if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                            dvT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";

                                            dvExcel[id] += drvA.ToString() + ",";

                                            dvExcelT[id] += drvAT.ToString() + ",";

                                            if (qsrq[k] != null)
                                                zyDu[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                            if (qsrqT[k] != null)
                                                zyDuT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";
                                        }

                                        if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //{
                                            du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";

                                            duT[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvAT.ToString() + ";";
                                            //}
                                            //else
                                            //{
                                            //    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";

                                            //    duT[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvAT.ToString(), num) + ";";

                                            //}
                                        }
                                    }
                                }
                                #endregion

                                #region 累计
                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                                DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                                if (dtDiff != null && dtDiff.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dtDiff.Rows.Count; i++)
                                    {
                                        num = dtDiff.Rows[i]["小数点数"].ToString();

                                        pName = dtDiff.Rows[i]["月点"].ToString();

                                        drvA = 0;
                                        drvAT = 0;

                                        if (qsrq[k] != null)
                                            ek.GetHisValueByTime(pName, sDate1, ref ret, ref drvA);
                                        else
                                            drvA = 0;

                                        if (qsrqT[k] != null)
                                            ek.GetHisValueByTime(pName, sDate1T, ref ret, ref drvAT);
                                        else
                                            drvAT = 0;

                                        if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                            dvT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";

                                            dvExcel[id] += drvA.ToString() + ",";

                                            dvExcelT[id] += drvAT.ToString() + ",";

                                            if (qsrq[k] != null)
                                                zyDu[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                            if (qsrqT[k] != null)
                                                zyDuT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";
                                        }

                                        if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //{
                                            du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";

                                            duT[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvAT.ToString() + ";";
                                            //}
                                            //else
                                            //{
                                            //    du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";

                                            //    duT[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvAT.ToString(), num) + ";";

                                            //}
                                        }
                                    }
                                }

                                #endregion

                                #region SQL

                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                                DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                                if (dtSQL != null && dtSQL.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dtSQL.Rows.Count; i++)
                                    {
                                        num = dtSQL.Rows[i]["小数点数"].ToString();

                                        sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                        if (qsrq[k] != null)
                                        {
                                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                            {
                                                sql = sql.Replace("&bt&", qsrq[k].ToString());
                                                sql = sql.Replace("&et&", sDate1);
                                            }

                                            obj = DBsql.RunSingle(sql, out errMsg);

                                            res = "";
                                            if (obj != null && obj != "")
                                            {
                                                if (obj.ToString() != "")
                                                    res = obj.ToString();
                                                else
                                                    res = "0";
                                            }
                                            else
                                            { res = "0"; }
                                        }
                                        else
                                            res = "0";

                                        sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                        if (qsrqT[k] != null)
                                        {
                                            if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                            {
                                                sql = sql.Replace("&bt&", qsrqT[k].ToString());
                                                sql = sql.Replace("&et&", sDate1T);
                                            }

                                            obj = DBsql.RunSingle(sql, out errMsg);

                                            resT = "";
                                            if (obj != null && obj != "")
                                            {
                                                if (obj.ToString() != "")
                                                    resT = obj.ToString();
                                                else
                                                    resT = "0";
                                            }
                                            else
                                                resT = "0";
                                        }
                                        else
                                            resT = "0";

                                        if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(res, num) + ",";

                                            dvT[id] += sh.ShowPoint(resT, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(res, "-1") + ",";

                                            dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";

                                            if (qsrq[k] != null)
                                                zyDu[id] += sh.ShowPoint(res, num) + ",";

                                            if (qsrqT[k] != null)
                                                zyDuT[id] += sh.ShowPoint(resT, num) + ",";
                                        }

                                        if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //{
                                            du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";

                                            duT[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + resT + ";";
                                            //}
                                            //else
                                            //{
                                            //   du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                            //    duT[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                            //}
                                        }
                                    }
                                }
                                #endregion

                                #region 电量
                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                                DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                                if (dtDL.Rows.Count > 0 && dtDL != null)
                                {
                                    for (int i = 0; i < dtDL.Rows.Count; i++)
                                    {
                                        num = dtDL.Rows[i]["小数点数"].ToString();

                                        dlID = dtDL.Rows[i]["电量点"].ToString();

                                        if (qsrq[k] != null)
                                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq[k], jsrq[k], bm).ToString());
                                        else
                                            drvA = 0;

                                        mon = "";
                                        mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                        res = "";
                                        try
                                        { res = StrHelper.Cale(mon); }
                                        catch
                                        { res = "0"; }

                                        if (qsrqT[k] != null)
                                            drvAT = double.Parse(pc.GetPower(drvAT, dlID, qsrqT[k], jsrqT[k], bm).ToString());
                                        else
                                            drvAT = 0;

                                        mon = "";
                                        mon = drvAT.ToString() + dtDL.Rows[i]["公式"].ToString();

                                        resT = "";
                                        try
                                        { resT = StrHelper.Cale(mon); }
                                        catch
                                        { resT = "0"; }

                                        if (dtDL.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(res, num) + ",";

                                            dvT[id] += sh.ShowPoint(resT, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(res, "-1") + ",";

                                            dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";

                                            if (qsrq[k] != null)
                                                zyDu[id] += sh.ShowPoint(res, num) + ",";

                                            if (qsrqT[k] != null)
                                                zyDuT[id] += sh.ShowPoint(resT, num) + ",";
                                        }

                                        if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //{
                                            du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";

                                            duT[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + resT + ";";
                                            //}
                                            //else
                                            //{
                                            //    du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                            //    duT[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                            //}
                                        }
                                    }
                                }

                                #endregion

                                #region 其它
                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                                DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                                if (dtQT.Rows.Count > 0 && dtQT != null)
                                {
                                    for (int i = 0; i < dtQT.Rows.Count; i++)
                                    {
                                        num = dtQT.Rows[i]["小数点数"].ToString();

                                        #region 购网电量
                                        if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                        {
                                            string re = "0";

                                            if (qsrq[k] != null)
                                                re = um.gwdl(qsrq[k], jsrq[k], unit, "mx");
                                            //re = um.gwdl(qsrq[k], jsrq[k], unit);

                                            string reT = "0";

                                            if (qsrqT[k] != null)
                                                reT = um.gwdl(qsrqT[k], jsrqT[k], unit, "mx");
                                            //reT = um.gwdl(qsrqT[k], jsrqT[k], unit);

                                            if (dtQT.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                                dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                                dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";

                                                dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";

                                                if (qsrq[k] != null)
                                                    zyDu[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                                if (qsrqT[k] != null)
                                                    zyDuT[id] += sh.ShowPoint(reT.ToString(), num) + ",";
                                            }

                                            if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";

                                                duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                            }
                                        }
                                        #endregion

                                        #region 入炉煤低位发热量
                                        if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                        {
                                            string rlm = "";
                                            string rlmT = "";

                                            if (qsrq[k] != null)
                                                rlm = um.rlmdwfrl("月报", qsrq[k], jsrq[k], 1);
                                            else
                                                rlm = "0";

                                            if (qsrqT[k] != null)
                                                rlmT = um.rlmdwfrl("月报", qsrqT[k], jsrqT[k], 1);
                                            else
                                                rlmT = "0";

                                            if (dtQT.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(rlm, num) + ",";

                                                dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                                dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";

                                                dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                            }

                                            if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";

                                                duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                            }
                                        }
                                        #endregion

                                        #region K2(q2)
                                        if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                        {
                                            string pid = dtQT.Rows[i]["参数ID"].ToString();

                                            string val = "0";
                                            string valT = "0";

                                            if (qsrq[k] != null)
                                                val = um.K2(pid, du, unit);

                                            if (qsrqT[k] != null)
                                                valT = um.K2(pid, duT, unit);

                                            if (dtQT.Rows[i]["显示"].ToString() == "1")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                                dv[id] += sh.ShowPoint(val, num) + ",";

                                                dvT[id] += sh.ShowPoint(valT, num) + ",";

                                                dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                                dvExcelT[id] += sh.ShowPoint(valT, "-1") + ",";
                                            }

                                            if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                            {
                                                id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                                du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";

                                                duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + valT + ";";
                                            }
                                        }
                                        #endregion
                                    }
                                }
                                #endregion

                                #region 公式
                                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                                DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                                if (dtMon != null && dtMon.Rows.Count > 0)
                                {
                                    for (int i = 0; i < dtMon.Rows.Count; i++)
                                    {
                                        num = dtMon.Rows[i]["小数点数"].ToString();

                                        string pMon = dtMon.Rows[i]["公式"].ToString();

                                        string paras = dtMon.Rows[i]["公式参数"].ToString();

                                        string month = pm.retMon(pMon, paras, du);
                                        string monthT = pm.retMon(pMon, paras, duT);

                                        //本期
                                        if (month != "")
                                        {
                                            res = "";
                                            try
                                            {
                                                res = StrHelper.Cale(month);
                                                //res = sh.ShowPoint(res, num);
                                            }
                                            catch
                                            { res = "0"; }
                                        }

                                        //同期
                                        if (monthT != "")
                                        {
                                            resT = "";
                                            try
                                            {
                                                resT = StrHelper.Cale(monthT);
                                                //resT = sh.ShowPoint(resT, num);
                                            }
                                            catch
                                            { resT = "0"; }
                                        }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            if (qsrq[k] != null)
                                            {
                                                dv[id] += sh.ShowPoint(res, num) + ",";
                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            }
                                            else
                                            {
                                                dv[id] += sh.ShowPoint("0", num) + ",";
                                                dvExcel[id] += "0" + ",";
                                            }

                                            if (qsrqT[k] != null)
                                            {
                                                dvT[id] += sh.ShowPoint(resT, num) + ",";
                                                dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";
                                            }
                                            else
                                            {
                                                dvT[id] += sh.ShowPoint("0", num) + ",";
                                                dvExcelT[id] += "0" + ",";
                                            }

                                            if (qsrq[k] != null)
                                                zyDu[id] += sh.ShowPoint(res, num) + ",";

                                            if (qsrqT[k] != null)
                                                zyDuT[id] += sh.ShowPoint(resT, num) + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //{
                                            du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";

                                            duT[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, "-1") + ";";
                                            //}
                                            //else
                                            //{
                                            //    du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                            //    duT[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                            //}
                                        }

                                    }
                                }

                                #endregion

                            }
                        }
                        else
                            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报表,日值部分,公式级别读取失败......");
                    }
                }

                #endregion

                #region 最优值

                //本年最优
                if (zy != null)
                {
                    string strB = "";
                    string strT = "";

                    for (int i = 0; i < zy.Length; i++)
                    {
                        if (zy[i] != null && zy[i] != "")
                        {
                            strB = pm.GetMaxOrMixStr(zyDu[i], zy[i]);
                            strT = pm.GetMaxOrMixStr(zyDuT[i], zy[i]);

                            if (strB != "")
                                zyB[i] = strB;

                            if (strT != "")
                                zyT[i] = strT;
                        }
                        else
                        {
                            zyB[i] = "/";
                            zyT[i] = "/";
                        }
                    }
                }

                #endregion

                #region 年值计算

                sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

                DataTable dtLelYear = DBsql.RunDataTable(sql, out errMsg);

                if (dtLelYear.Rows.Count > 0)
                {
                    if (isDay == 0)
                        sDate1 = DateTime.Parse(sDate[11]).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss"); // DateTime.Now.AddHours(-1).ToString("yyyy-MM-dd H:59:59");
                    else
                        sDate1 = DateTime.Parse(sDate[11]).ToString("yyyy-MM-dd 23:59:59");

                    sDate1T = DateTime.Parse(sDateT[11]).ToString("yyyy-MM-dd 23:59:59");

                    for (int j = 0; j < dtLelYear.Rows.Count; j++)
                    {
                        string gsjb = dtLelYear.Rows[j]["公式级别"].ToString();

                        #region 平均
                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                        DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                        if (dtAvg != null && dtAvg.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtAvg.Rows.Count; i++)
                            {
                                num = dtAvg.Rows[i]["小数点数"].ToString();

                                pName = dtAvg.Rows[i]["年点"].ToString();

                                if (sDate1 != "")
                                    ek.GetHisValueByTime(pName, sDate1, ref ret, ref drvA);
                                else
                                    drvA = 0;

                                if (sDate1T != "")
                                    ek.GetHisValueByTime(pName, sDate1T, ref ret, ref drvAT);
                                else
                                    drvAT = 0;

                                if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                    dvT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";

                                    dvExcel[id] += drvA.ToString() + ",";

                                    dvExcelT[id] += drvAT.ToString() + ",";
                                }

                                if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    //{
                                    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";

                                    duT[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvAT.ToString() + ";";
                                    //}
                                    //else
                                    //{
                                    //    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";

                                    //    duT[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvAT.ToString(), num) + ";";
                                    //}
                                }
                            }
                        }
                        #endregion

                        #region 累计
                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                        DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                        if (dtDiff != null && dtDiff.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtDiff.Rows.Count; i++)
                            {
                                num = dtDiff.Rows[i]["小数点数"].ToString();

                                pName = dtDiff.Rows[i]["年点"].ToString();

                                drvA = 0;
                                drvAT = 0;

                                if (sDate1 != "")
                                    ek.GetHisValueByTime(pName, sDate1, ref ret, ref drvA);
                                else
                                    drvA = 0;

                                if (sDate1T != "")
                                    ek.GetHisValueByTime(pName, sDate1T, ref ret, ref drvAT);
                                else
                                    drvAT = 0;

                                if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                    dvT[id] += sh.ShowPoint(drvAT.ToString(), num) + ",";

                                    dvExcel[id] += drvA.ToString() + ",";

                                    dvExcelT[id] += drvAT.ToString() + ",";
                                }

                                if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    //{
                                    du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";

                                    duT[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvAT.ToString() + ";";
                                    //}
                                    //else
                                    //{
                                    //   du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";

                                    //    duT[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvAT.ToString(), num) + ";";
                                    //}
                                }
                            }
                        }

                        #endregion

                        #region SQL

                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                        DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                        if (dtSQL != null && dtSQL.Rows.Count > 0)
                        {
                            for (int i = 0; i < dtSQL.Rows.Count; i++)
                            {
                                num = dtSQL.Rows[i]["小数点数"].ToString();

                                sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                if (sDate1 != "")
                                {
                                    if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                    {
                                        sql = sql.Replace("&bt&", qsrq[0].ToString());
                                        sql = sql.Replace("&et&", sDate1);
                                    }

                                    obj = DBsql.RunSingle(sql, out errMsg);

                                    res = "";
                                    if (obj != null && obj != "")
                                    {
                                        if (obj.ToString() != "")
                                            res = obj.ToString();
                                        else
                                            res = "0";
                                    }
                                    else
                                    { res = "0"; }
                                }
                                else
                                    res = "0";

                                sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                if (sDate1T != "")
                                {
                                    if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                    {
                                        sql = sql.Replace("&bt&", qsrqT[0].ToString());
                                        sql = sql.Replace("&et&", sDate1T);
                                    }

                                    obj = DBsql.RunSingle(sql, out errMsg);

                                    resT = "";
                                    if (obj != null && obj != "")
                                    {
                                        if (obj.ToString() != "")
                                            resT = obj.ToString();
                                        else
                                            resT = "0";
                                    }
                                    else
                                        resT = "0";
                                }
                                else
                                    resT = "0";

                                if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";

                                    dvT[id] += sh.ShowPoint(resT, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";

                                    dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";
                                }

                                if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    //{
                                    du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";

                                    duT[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + resT + ";";
                                    //}
                                    //else
                                    //{
                                    //    du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                    //    duT[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                    //}
                                }
                            }
                        }
                        #endregion

                        #region 电量
                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                        DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                        if (dtDL.Rows.Count > 0 && dtDL != null)
                        {
                            for (int i = 0; i < dtDL.Rows.Count; i++)
                            {
                                num = dtDL.Rows[i]["小数点数"].ToString();

                                dlID = dtDL.Rows[i]["电量点"].ToString();

                                drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq[0], DateTime.Parse(sDate[11]).ToString("yyyy-MM-dd H:mm:ss"), bm).ToString());

                                mon = "";
                                mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                res = "";
                                try
                                { res = StrHelper.Cale(mon); }
                                catch
                                { res = "0"; }

                                drvAT = double.Parse(pc.GetPower(drvAT, dlID, qsrqT[0], jsrqT[11], bm).ToString());

                                mon = "";
                                mon = drvAT.ToString() + dtDL.Rows[i]["公式"].ToString();

                                resT = "";
                                try
                                { resT = StrHelper.Cale(mon); }
                                catch
                                { resT = "0"; }

                                if (dtDL.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";

                                    dvT[id] += sh.ShowPoint(resT, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";

                                    dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";
                                }

                                if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    //{
                                    du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";

                                    duT[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + resT + ";";
                                    //}
                                    //else
                                    //{
                                    //    du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                    //    duT[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                    //}
                                }
                            }
                        }

                        #endregion

                        #region 其它
                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                        DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                        if (dtQT.Rows.Count > 0 && dtQT != null)
                        {
                            for (int i = 0; i < dtQT.Rows.Count; i++)
                            {
                                num = dtQT.Rows[i]["小数点数"].ToString();

                                #region 购网电量
                                if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                {
                                    string re = um.gwdl(qsrq[0], DateTime.Parse(sDate[11]).AddSeconds(+1).ToString("yyyy-MM-dd H:mm:ss"), unit, "mx");
                                    //re = um.gwdl(qsrq[k], jsrq[k], unit, "mx");
                                    string reT = um.gwdl(qsrqT[0], jsrqT[11], unit, "mx");

                                    if (dtQT.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                        dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                        dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";

                                        dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";
                                    }

                                    if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                        du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";

                                        duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                    }
                                }
                                #endregion

                                #region 入炉煤低位发热量
                                if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                {
                                    string rlm = "";
                                    string rlmT = "";

                                    if (qsrq[0] != null)
                                        rlm = um.rlmdwfrl("年报", qsrq[0], DateTime.Parse(sDate[11]).AddSeconds(+1).ToString("yyyy-MM-dd H:mm:ss"), 1);
                                    else
                                        rlm = "0";

                                    if (qsrqT[0] != null)
                                        rlmT = um.rlmdwfrl("年报", qsrqT[0], jsrqT[11], 1);
                                    else
                                        rlmT = "0";

                                    if (dtQT.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(rlm, num) + ",";

                                        dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";

                                        dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                    }

                                    if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        //{
                                        du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";

                                        duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                        //}
                                        //else
                                        //{
                                        //    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";

                                        //    duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlmT, num) + ";";
                                        //}
                                    }
                                }
                                #endregion

                                #region K2(q2)
                                if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                {
                                    string pid = dtQT.Rows[i]["参数ID"].ToString();

                                    string val = "0";
                                    string valT = "0";

                                    if (qsrq[0] != null)
                                        val = um.K2(pid, du, 0);

                                    if (qsrqT[0] != null)
                                        valT = um.K2(pid, duT, 0);

                                    if (dtQT.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                        id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(val, num) + ",";

                                        dvT[id] += sh.ShowPoint(valT, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                        dvExcelT[id] += sh.ShowPoint(valT, "-1") + ",";
                                    }

                                    if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                        du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";

                                        duT[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + valT + ";";
                                    }
                                }
                                #endregion

                            }
                        }
                        #endregion

                        #region 公式
                        sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                        DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                        if (dtMon != null && dtMon.Rows.Count > 0)
                        {
                            string pMon = "";
                            string paras = "";
                            string month = "";
                            string monthT = "";

                            for (int i = 0; i < dtMon.Rows.Count; i++)
                            {
                                num = dtMon.Rows[i]["小数点数"].ToString();

                                pMon = dtMon.Rows[i]["公式"].ToString();

                                paras = dtMon.Rows[i]["公式参数"].ToString();

                                month = pm.retMon(pMon, paras, du);
                                monthT = pm.retMon(pMon, paras, duT);

                                //本期
                                if (month != "")
                                {
                                    res = "";
                                    try
                                    {
                                        res = StrHelper.Cale(month);
                                        //res = sh.ShowPoint(res, num);
                                    }
                                    catch
                                    { res = "0"; }
                                }

                                //同期
                                if (monthT != "")
                                {
                                    resT = "";
                                    try
                                    {
                                        resT = StrHelper.Cale(monthT);
                                        //resT = sh.ShowPoint(resT, num);
                                    }
                                    catch
                                    { resT = "0"; }
                                }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";

                                    dvT[id] += sh.ShowPoint(resT, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";

                                    dvExcelT[id] += sh.ShowPoint(resT, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    //{
                                    du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";

                                    duT[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, "-1") + ";";
                                    //}
                                    //else
                                    //{
                                    //    du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                    //    duT[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(resT, num) + ";";
                                    //}
                                }

                            }
                        }

                        #endregion
                    }
                }
                else
                    LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 年明细报表,年值部分,公式级别读取失败......");

                #endregion
            }
            catch (Exception ce)
            { LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvT);
            list.Add(zyB);
            list.Add(zyT);
            list.Add(dvExcel);
            list.Add(dvExcelT);

            return list;
        }

        /// <summary>
        /// 月、季、年报表【芜湖短信日报】
        /// 机组轮转
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="pType"></param>
        /// <param name="qsrq"></param>
        /// <param name="jsrq"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepMonthByDX(string repName, string repType, string pType, string qsrq, string jsrq, string qsrqT, string jsrqT, bool isDay)
        {
            int id;
            object obj;
            int ret = 0;
            double drvA = 0;
            double drvB = 0;

            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string unit = "";
            string pName = "";
            string dlID = "";

            //基础数据值
            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] dvT = null;
            string[] duT = null;

            string[] dvExcel = null;
            string[] dvExcelT = null;

            string sDate = "";

            if (isDay == true)
                //sDate = DateTime.Parse(jsrq).ToString("yyyy-MM-dd H:59:59");
                sDate = DateTime.Parse(jsrq).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");
            else
                sDate = DateTime.Parse(jsrq).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

            string sDateT = DateTime.Parse(jsrqT).AddSeconds(-1).ToString("yyyy-MM-dd H:mm:ss");

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 1);
            countKey = pm.GetCountkey(repName, 1);

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 日报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            //try
            //{
            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];
            dvT = new string[count + 1];
            duT = new string[countKey + 1];

            dvExcel = new string[count + 1];
            dvExcelT = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

            //机组数据轮转
            sql = "SELECT DISTINCT 机组 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0";

            DataTable dtLevUnit = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevUnit != null && dtLevUnit.Rows.Count > 0)
            {
                for (int k = 0; k < dtLevUnit.Rows.Count; k++)
                {
                    unit = dtLevUnit.Rows[k]["机组"].ToString();

                    sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组!=0 and 公式级别!=0";

                    DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                    if (dtLel.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtLel.Rows.Count; j++)
                        {
                            string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                            #region 电量
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                            DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDL.Rows.Count > 0 && dtDL != null)
                            {
                                for (int i = 0; i < dtDL.Rows.Count; i++)
                                {
                                    num = dtDL.Rows[i]["小数点数"].ToString();

                                    dlID = dtDL.Rows[i]["电量点"].ToString();

                                    drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                                    mon = "";
                                    mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }

                                    drvB = double.Parse(pc.GetPower(drvB, dlID, qsrqT, jsrqT, bm).ToString());

                                    mon = "";
                                    mon = drvB.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dvT[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region 其它
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                            DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                            if (dtQT.Rows.Count > 0 && dtQT != null)
                            {
                                for (int i = 0; i < dtQT.Rows.Count; i++)
                                {
                                    num = dtQT.Rows[i]["小数点数"].ToString();

                                    #region 购网电量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                    {
                                        string re = um.gwdl(qsrq, jsrq, int.Parse(unit), "mx");

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                            dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                        }

                                        //同期
                                        string reT = um.gwdl(qsrqT, jsrqT, int.Parse(unit), "mx");

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                        }

                                    }
                                    #endregion

                                    #region 入炉煤低位发热量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                    {
                                        string rlm = um.rlmdwfrl("月报", qsrq, jsrq, 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(rlm, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                            //else
                                            //  du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                        }

                                        string rlmT = um.rlmdwfrl(repType, qsrqT, jsrqT, 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                            //else
                                            //    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlmT, num) + ";";
                                        }
                                    }
                                    #endregion

                                    #region K2(q2)
                                    if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                    {
                                        string pid = dtQT.Rows[i]["参数ID"].ToString();

                                        string val = "0";
                                        string valT = "0";

                                        val = um.K2(pid, du, int.Parse(unit));
                                        valT = um.K2(pid, duT, int.Parse(unit));

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(val, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                            dvT[id] += sh.ShowPoint(valT.ToString(), num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(valT.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                            duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + valT.ToString() + ";";
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            #region 公式
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                            DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                            if (dtMon != null && dtMon.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtMon.Rows.Count; i++)
                                {
                                    num = dtMon.Rows[i]["小数点数"].ToString();

                                    string pMon = dtMon.Rows[i]["公式"].ToString();

                                    string paras = dtMon.Rows[i]["公式参数"].ToString();

                                    string month = pm.retMon(pMon, paras, du, unit);
                                    string monthT = pm.retMon(pMon, paras, duT, unit);

                                    if (month != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(month);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(res, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                            //else
                                            //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        }
                                    }

                                    if (monthT != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(monthT);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            dvT[id] += sh.ShowPoint(res, num) + ",";

                                            dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            //else
                                            //    duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取机组信息失败......");

            //全厂数据
            sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 公式级别!=0";

            DataTable dtLevZ = DBsql.RunDataTable(sql, out errMsg);

            if (dtLevZ.Rows.Count > 0)
            {
                for (int j = 0; j < dtLevZ.Rows.Count; j++)
                {
                    string gsjb = dtLevZ.Rows[j]["公式级别"].ToString();

                    #region 电量
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='电量' and 公式级别=" + gsjb;

                    DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                    if (dtDL.Rows.Count > 0 && dtDL != null)
                    {
                        for (int i = 0; i < dtDL.Rows.Count; i++)
                        {
                            num = dtDL.Rows[i]["小数点数"].ToString();

                            dlID = dtDL.Rows[i]["电量点"].ToString();

                            drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq, jsrq, bm).ToString());

                            mon = "";
                            mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(res, num) + ",";

                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    du[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }

                            drvB = double.Parse(pc.GetPower(drvB, dlID, qsrqT, jsrqT, bm).ToString());

                            mon = "";
                            mon = drvB.ToString() + dtDL.Rows[i]["公式"].ToString();

                            res = "";
                            try
                            { res = StrHelper.Cale(mon); }
                            catch
                            { res = "0"; }

                            if (dtDL.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                dvT[id] += sh.ShowPoint(res, num) + ",";

                                dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                            }

                            if (dtDL.Rows[i]["参数ID"].ToString() != "")
                            {
                                id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                //if (num == "")
                                duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                //else
                                //    duT[id] += dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                            }
                        }
                    }

                    #endregion

                    #region 其它
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='其它' and 公式级别=" + gsjb;

                    DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                    if (dtQT.Rows.Count > 0 && dtQT != null)
                    {
                        for (int i = 0; i < dtQT.Rows.Count; i++)
                        {
                            num = dtQT.Rows[i]["小数点数"].ToString();

                            #region 购网电量
                            if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                            {
                                string re = um.gwdl(qsrq, jsrq, 0, "mx");

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                    dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                }

                                string reT = um.gwdl(qsrqT, jsrqT, 0, "mx");

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(reT.ToString(), num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(reT.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + reT.ToString() + ";";
                                }

                            }
                            #endregion

                            #region 入炉煤低位发热量
                            if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                            {
                                string rlm = um.rlmdwfrl("月报", qsrq, jsrq, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(rlm, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                    //else
                                    //    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                }

                                string rlmT = um.rlmdwfrl(repType, qsrqT, jsrqT, 1);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(rlmT, num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(rlmT, "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + rlmT + ";";
                                    //else
                                    //    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlmT, num) + ";";
                                }
                            }
                            #endregion

                            #region K2(q2)
                            if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                            {
                                string pid = dtQT.Rows[i]["参数ID"].ToString();

                                string val = "0";
                                string valT = "0";

                                val = um.K2(pid, du, 0);
                                valT = um.K2(pid, duT, 0);

                                if (dtQT.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(val, num) + ",";

                                    dvExcel[id] += sh.ShowPoint(val, "-1") + ",";

                                    dvT[id] += sh.ShowPoint(valT.ToString(), num) + ",";

                                    dvExcelT[id] += sh.ShowPoint(valT.ToString(), "-1") + ",";
                                }

                                if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                    du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                    duT[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + valT.ToString() + ";";
                                }
                            }
                            #endregion
                        }
                    }
                    #endregion

                    #region 公式
                    sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=0 and 参数类型='公式' and 公式级别=" + gsjb;

                    DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                    if (dtMon != null && dtMon.Rows.Count > 0)
                    {
                        for (int i = 0; i < dtMon.Rows.Count; i++)
                        {
                            num = dtMon.Rows[i]["小数点数"].ToString();

                            string pMon = dtMon.Rows[i]["公式"].ToString();

                            string paras = dtMon.Rows[i]["公式参数"].ToString();

                            string month = pm.retMon(pMon, paras, du);
                            string monthT = pm.retMon(pMon, paras, duT);

                            if (month != "")
                            {
                                res = "";
                                try
                                {
                                    res = StrHelper.Cale(month);
                                    //res = sh.ShowPoint(res, num);
                                }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dv[id] += sh.ShowPoint(res, num) + ",";
                                    dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //    du[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                }
                            }

                            if (monthT != "")
                            {
                                res = "";
                                try
                                {
                                    res = StrHelper.Cale(monthT);
                                    //res = sh.ShowPoint(res, num);
                                }
                                catch
                                { res = "0"; }

                                if (dtMon.Rows[i]["显示"].ToString() == "1")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                    dvT[id] += sh.ShowPoint(res, num) + ",";
                                    dvExcelT[id] += sh.ShowPoint(res, "-1") + ",";
                                }

                                if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                {
                                    id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                    //if (num == "")
                                    duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                    //else
                                    //  duT[id] += dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";

                                }
                            }
                        }
                    }

                    #endregion
                }
            }

            //}
            //catch (Exception ce)
            //{ LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 程序异常: " + ce.Message); }

            for (int i = 1; i < du.Length; i++)
            {
                if (du[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Success, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + du[i].ToString());
            }

            for (int i = 1; i < dv.Length; i++)
            {
                if (dv[i] != null)
                    LogHelper.WriteLog(LogHelper.EnLogType.Warn, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + dv[i].ToString());
            }

            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvT);
            list.Add(dvExcel);
            list.Add(dvExcelT);

            return list;
        }

        public DataTable RetTableXZ(string unit, string repName)
        {
            string sql = "select 参数名,参数顺序,参数类型 from t_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数顺序!=0";

            return DBsql.RunDataTable(sql, out errMsg);
        }


        /// <summary>
        /// 化学日报
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="qsrq"></param>
        /// <param name="jsrq"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepHourHX(string repName, int unit, DateTime date, bool isDay)
        {
            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string pName = "";
            string dlID = "";
            string repType = "小时点";
            int hours = 0;

            int ret = 0;
            int id;
            object obj;
            double drvA = 0;
            double drvB = 0;
            string sDate = "";

            //基础数据值
            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] dvExcel = null;

            DateTime dtNow = DateTime.Now;

            ArrayList list = new ArrayList();

            if (isDay == true)
                hours = dtNow.Hour + 1;
            else
                hours = 24;

            count = pm.GetCountCyd(repName, 1);
            countKey = pm.GetCountkey(repName, 1);

            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];

            dvExcel = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=1 and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");

            try
            {

                #region 平均
                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=1";

                DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                if (dtAvg != null && dtAvg.Rows.Count > 0)
                {
                    for (int i = 0; i < dtAvg.Rows.Count; i++)
                    {
                        num = dtAvg.Rows[i]["小数点数"].ToString();

                        pName = dtAvg.Rows[i][repType].ToString();

                        for (int j = 0; j < 24; j++)
                        {
                            sDate = date.AddHours(+j).ToString("yyyy-MM-dd H:59:59");

                            if (DateTime.Parse(sDate) < dtNow && pName != "")
                                ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                            else
                                drvA = 0;

                            if (dtAvg.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                dvExcel[id] += drvA.ToString() + ",";
                            }
                        }
                    }
                }
                #endregion

                #region 公式
                sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=1";

                DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                if (dtMon != null && dtMon.Rows.Count > 0)
                {
                    for (int i = 0; i < dtMon.Rows.Count; i++)
                    {
                        for (int j = 0; j < 24; j++)
                        {
                            if (dtMon.Rows[i]["显示"].ToString() == "1")
                            {
                                id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                dv[id] += "-,"; //sh.ShowPoint("-9.99", num) + ",";
                            }
                        }
                    }
                }

                #endregion

            }
            catch (Exception ce)
            {
            }
            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvExcel);

            return list;
        }

        /// <summary>
        /// 化学月报表
        /// </summary>
        /// <param name="repName"></param>
        /// <param name="repType"></param>
        /// <param name="date"></param>
        /// <param name="isDay"></param>
        /// <returns></returns>
        public ArrayList RetArrsRepMonthByHX(string repName, int unit, DateTime date, int isDay)
        {
            int days;
            string fDay = "";
            string lDay = "";
            int id;
            object obj;
            int ret = 0;
            double drvA = 0;
            double drvB = 0;
            string sDate = "";

            string bm = "";
            string mon = "";
            string res = "";
            string num = "";
            string pName = "";
            string dlID = "";

            string[] zb = null;
            string[] un = null;
            string[] lay = null;
            string[] dv = null;
            string[] du = null;
            string[] qsrq = null;
            string[] jsrq = null;

            string[] dvExcel = null;

            ArrayList list = new ArrayList();

            count = pm.GetCountCyd(repName, 2);
            countKey = pm.GetCountkey(repName, 2);

            days = DateTime.DaysInMonth(date.Year, date.Month);

            #region 日期
            if (isDay == 0)
            {
                qsrq = new string[days + 1];
                jsrq = new string[days + 1];

                for (int i = 1; i < DateTime.Now.Day; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = DateTime.Now.ToString("yyyy-MM-dd 0:00:00");
            }
            else
            {
                qsrq = new string[days + 1];
                jsrq = new string[days + 1];

                for (int i = 1; i < days + 1; i++)
                {
                    qsrq[i] = date.Year + "-" + date.Month + "-" + i + " 00:00:00";
                    jsrq[i] = DateTime.Parse(date.Year + "-" + date.Month + "-" + i + " 00:00:00").AddDays(1).ToString();
                }
                fDay = qsrq[1];
                lDay = jsrq[days];
            }

            #endregion

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报开始.......");

            LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " count Value=" + count + " countKey Value=" + countKey);

            //try
            //{
            zb = new string[count + 1];
            un = new string[count + 1];
            lay = new string[count + 1];
            dv = new string[count + 1];
            du = new string[countKey + 1];

            dvExcel = new string[count + 1];

            //直接取出中文描速,单位,设计值
            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数顺序!=0 order by 参数顺序";

            DataTable dtInfo = DBsql.RunDataTable(sql, out errMsg);

            if (dtInfo != null && dtInfo.Rows.Count > 0)
            {
                for (int k = 0; k < dtInfo.Rows.Count; k++)
                {
                    id = int.Parse(dtInfo.Rows[k]["参数顺序"].ToString());

                    zb[id] = dtInfo.Rows[k]["参数名"].ToString();
                    un[id] = dtInfo.Rows[k]["单位"].ToString();
                    lay[id] = dtInfo.Rows[k]["设计值"].ToString();
                }
            }
            else
                LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 读取[中文描速,单位,设计值]信息失败......");


            for (int k = 1; k <= 31; k++)
            {
                if (k < qsrq.Length)
                {
                    if (qsrq[k] != null)
                        sDate = DateTime.Parse(qsrq[k]).ToString("yyyy-MM-dd 23:59:59");

                    sql = "SELECT DISTINCT 公式级别 FROM T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 公式级别!=0";

                    DataTable dtLel = DBsql.RunDataTable(sql, out errMsg);

                    if (dtLel.Rows.Count > 0)
                    {
                        for (int j = 0; j < dtLel.Rows.Count; j++)
                        {
                            string gsjb = dtLel.Rows[j]["公式级别"].ToString();

                            #region 平均
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='平均' and 公式级别=" + gsjb;

                            DataTable dtAvg = DBsql.RunDataTable(sql, out errMsg);

                            if (dtAvg != null && dtAvg.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtAvg.Rows.Count; i++)
                                {
                                    num = dtAvg.Rows[i]["小数点数"].ToString();

                                    pName = dtAvg.Rows[i]["日点"].ToString();

                                    if (qsrq[k] != null)
                                        ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    else
                                        drvA = 0;

                                    if (dtAvg.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtAvg.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtAvg.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        //else
                                        //    du[id] = dtAvg.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 累计
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='累计' and 公式级别=" + gsjb;

                            DataTable dtDiff = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDiff != null && dtDiff.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtDiff.Rows.Count; i++)
                                {
                                    num = dtDiff.Rows[i]["小数点数"].ToString();

                                    pName = dtDiff.Rows[i]["日点"].ToString();

                                    drvA = 0;
                                    if (qsrq[k] != null)
                                        ek.GetHisValueByTime(pName, sDate, ref ret, ref drvA);
                                    else
                                        drvA = 0;

                                    if (dtDiff.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(drvA.ToString(), num) + ",";

                                        dvExcel[id] += drvA.ToString() + ",";
                                    }

                                    if (dtDiff.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDiff.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + drvA.ToString() + ";";
                                        //else
                                        //    du[id] = dtDiff.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(drvA.ToString(), num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region SQL

                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='SQL' and 公式级别=" + gsjb;

                            DataTable dtSQL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtSQL != null && dtSQL.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtSQL.Rows.Count; i++)
                                {
                                    num = dtSQL.Rows[i]["小数点数"].ToString();

                                    sql = dtSQL.Rows[i]["SQL语句"].ToString();

                                    if (qsrq[k] != null)
                                    {
                                        if (sql.Contains("&bt&") && sql.Contains("&et&"))
                                        {
                                            sql = sql.Replace("&bt&", qsrq[k].ToString());
                                            sql = sql.Replace("&et&", sDate);
                                        }

                                        obj = DBsql.RunSingle(sql, out errMsg);

                                        res = "";
                                        if (obj != null && obj != "")
                                        {
                                            if (obj.ToString() != "")
                                                res = obj.ToString();
                                            else
                                                res = "0";
                                        }
                                        else
                                        { res = "0"; }
                                    }
                                    else
                                        res = "0";

                                    if (dtSQL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtSQL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtSQL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] = dtSQL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }
                            #endregion

                            #region 电量
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='电量' and 公式级别=" + gsjb;

                            DataTable dtDL = DBsql.RunDataTable(sql, out errMsg);

                            if (dtDL.Rows.Count > 0 && dtDL != null)
                            {
                                for (int i = 0; i < dtDL.Rows.Count; i++)
                                {
                                    num = dtDL.Rows[i]["小数点数"].ToString();

                                    dlID = dtDL.Rows[i]["电量点"].ToString();

                                    if (qsrq[k] != null)
                                        drvA = double.Parse(pc.GetPower(drvA, dlID, qsrq[k], jsrq[k], bm).ToString());
                                    else
                                        drvA = 0;

                                    mon = "";
                                    mon = drvA.ToString() + dtDL.Rows[i]["公式"].ToString();

                                    res = "";
                                    try
                                    { res = StrHelper.Cale(mon); }
                                    catch
                                    { res = "0"; }

                                    if (dtDL.Rows[i]["显示"].ToString() == "1")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数顺序"].ToString());

                                        dv[id] += sh.ShowPoint(res, num) + ",";

                                        dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                    }

                                    if (dtDL.Rows[i]["参数ID"].ToString() != "")
                                    {
                                        id = int.Parse(dtDL.Rows[i]["参数key"].ToString());

                                        //if (num == "")
                                        du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                        //else
                                        //    du[id] = dtDL.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, num) + ";";
                                    }
                                }
                            }

                            #endregion

                            #region 其它
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='其它' and 公式级别=" + gsjb;

                            DataTable dtQT = DBsql.RunDataTable(sql, out errMsg);

                            if (dtQT.Rows.Count > 0 && dtQT != null)
                            {
                                for (int i = 0; i < dtQT.Rows.Count; i++)
                                {
                                    num = dtQT.Rows[i]["小数点数"].ToString();

                                    #region 购网电量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "购网电量")
                                    {
                                        string re = "0";

                                        if (qsrq[k] != null)
                                            re = um.gwdl(qsrq[k].ToString(), jsrq[k].ToString(), unit);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(re.ToString(), num) + ",";

                                            dvExcel[id] += sh.ShowPoint(re.ToString(), "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + re.ToString() + ";";
                                        }
                                    }
                                    #endregion

                                    #region 入炉煤低位发热量
                                    if (dtQT.Rows[i]["参数名"].ToString() == "入炉煤低位发热量")
                                    {
                                        string rlm = um.rlmdwfrl("日报", qsrq[k], jsrq[k], 1);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(rlm, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(rlm, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + rlm + ";";
                                            //else
                                            //    du[id] = dtQT.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(rlm, num) + ";";
                                        }
                                    }
                                    #endregion

                                    #region K2(q2)
                                    if (dtQT.Rows[i]["参数名"].ToString() == "K2(q2)")
                                    {
                                        string pid = dtQT.Rows[i]["参数ID"].ToString();

                                        string val = um.K2(pid, du, unit);

                                        if (dtQT.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数顺序"].ToString());

                                            dv[id] += sh.ShowPoint(val, num) + ",";

                                            dvExcel[id] += sh.ShowPoint(val, "-1") + ",";
                                        }

                                        if (dtQT.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtQT.Rows[i]["参数key"].ToString());
                                            du[id] += dtQT.Rows[i]["参数ID"].ToString() + "," + val + ";";
                                        }
                                    }
                                    #endregion
                                }
                            }
                            #endregion

                            #region 公式
                            sql = "select * from T_sheet_sheetPara where 报表名称='" + repName + "' and 机组=" + unit + " and 参数类型='公式' and 公式级别=" + gsjb;

                            DataTable dtMon = DBsql.RunDataTable(sql, out errMsg);

                            if (dtMon != null && dtMon.Rows.Count > 0)
                            {
                                for (int i = 0; i < dtMon.Rows.Count; i++)
                                {
                                    num = dtMon.Rows[i]["小数点数"].ToString();

                                    string pMon = dtMon.Rows[i]["公式"].ToString();

                                    string paras = dtMon.Rows[i]["公式参数"].ToString();

                                    string month = pm.retMon(pMon, paras, du);

                                    if (month != "")
                                    {
                                        res = "";
                                        try
                                        {
                                            res = StrHelper.Cale(month);
                                            //res = sh.ShowPoint(res, num);
                                        }
                                        catch
                                        { res = "0"; }

                                        if (dtMon.Rows[i]["显示"].ToString() == "1")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数顺序"].ToString());

                                            if (qsrq[k] != null)
                                                dv[id] += sh.ShowPoint(res, num) + ",";
                                            else
                                                dv[id] += sh.ShowPoint("0", num) + ",";

                                            if (qsrq[k] != null)
                                                dvExcel[id] += sh.ShowPoint(res, "-1") + ",";
                                            else
                                                dvExcel[id] += "0" + ",";
                                        }

                                        if (dtMon.Rows[i]["参数ID"].ToString() != "")
                                        {
                                            id = int.Parse(dtMon.Rows[i]["参数key"].ToString());

                                            //if (num == "")
                                            //du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + res + ";";
                                            //else
                                            du[id] = dtMon.Rows[i]["参数ID"].ToString() + "," + sh.ShowPoint(res, "-1") + ";";
                                        }
                                    }
                                }
                            }

                            #endregion
                        }
                    }
                    else
                        LogHelper.WriteLog(LogHelper.EnLogType.Run, DateTime.Now.ToString("yyyy-MM-dd H:mm:ss") + " 月明细报表,日值部分,公式级别读取失败......");
                }
            }
           
            list.Add(zb);
            list.Add(un);
            list.Add(lay);
            list.Add(dv);
            list.Add(dvExcel);

            return list;
        }
    }
}
